//
//  DYPrintItem.m
//  DYPrintSDK
//
//  Created by mr.ye on 2023/11/20.
//

#import "DYPrintItem.h"


@implementation DYPrintItem
//2寸卷纸
- (NSData*)juanZhi:(UIImage *)img{

    NSMutableData * data=[[NSMutableData alloc]init];
    [data appendData: [DYPrintCmd printerEnabel]];
   
    [data appendData: [DYPrintCmd printerWake]];
    
    [data appendData: [DYPrintCmd printImageCmd:img]];
    
//    [data appendData: [DYPrintCmd compressPrintImageCmd:img]];
    
    
    [data appendData: [DYPrintCmd printerWalk:100]];
    
    [data appendData: [DYPrintCmd printerStop]];
    
    return data;

    
}
//折叠
- (NSData*)heiBiaoZhi:(UIImage *)img{

    
    NSMutableData *sendData = [[NSMutableData alloc] init];
 
    //唤醒打印机
    [sendData appendData:[DYPrintCmd printerEnabel]];

    //使能
    [sendData appendData:[DYPrintCmd printerWake]];


    //退纸
    [sendData appendData:[DYPrintCmd printerOut]];


    //打印图片
    [sendData appendData:[DYPrintCmd compressPrintImageCmd:img]];


    //标签纸定位
    [sendData appendData:[DYPrintCmd printerLocationA4:(DYPrintPaperTypeFolded)]];


    //进纸张
    [sendData appendData:[DYPrintCmd printerEnter]];

    //停止
    [sendData appendData:[DYPrintCmd printerStop]];
    

    return sendData;

    
}



- (IBAction)A4Label:(id)sender {
    
  
    UIImage * img1 = [UIImage imageNamed:@"a50img"];
    NSMutableData *sendData = [[NSMutableData alloc] init];
    
    //唤醒打印机
    [sendData appendData:[DYPrintCmd printerEnabel]];
    
    //使能
    [sendData appendData:[DYPrintCmd printerWake]];
    
    //退纸
    [sendData appendData: [DYPrintCmd printerOut]];
    
    
    //打印图片
    [sendData appendData:[DYPrintCmd compressPrintImageCmd:img1]];
    
    
    //A4定位
    [sendData appendData: [DYPrintCmd printerLocationA4:(DYPrintPaperTypeBlack)]];
    
   
    //进纸张
    [sendData appendData: [DYPrintCmd printerEnter]];
    
    
    [sendData appendData:[DYPrintCmd printerStop]];
    

}


-(void)getAllInfos:(TaskCompelete)call{
    //基础信息
    [[DYBLEManager sharedInstance].print getPrinterInfo:^(id  obj, NSUInteger code) {
        NSMutableDictionary * info =[[NSMutableDictionary alloc]initWithDictionary:obj];
        
        //型号
        [[DYBLEManager sharedInstance].print getMode:^(id  _Nonnull obj, NSUInteger code) {
            [info setValue:obj forKey:@"mode"];
            //浓度
            [[DYBLEManager sharedInstance].print getPrintColor:^(id  _Nonnull obj, NSUInteger code) {
                [info setValue:obj forKey:@"color"];
                
                NSLog(@"=信息===%@",info);
                call(info,@1000);
                
            }];
        }];
    }];
}
@end
